<template>
  <div>
    <div v-if="!detailsType">
      <div>
        <div v-if="companyInfoIndustry.company_id">
          <!-- <div v-if="companyInfoIndustry.company_id && (companyInfoIndustry.trademark_inside_info.nc || companyInfoIndustry.trademark_outside_info.es.nc || companyInfoIndustry.trademark_outside_info.us.nc || companyInfoIndustry.trademark_outside_info.jp.nc || companyInfoIndustry.trademark_outside_info.de.nc)"> -->
          <div>
            <!-- <div v-if="companyInfoIndustry.trademark_inside_info.nc"> -->
            <div class="title">
              国内商标：{{ companyInfoIndustry.trademark_inside_list.count }}
            </div>
            <div v-if="companyInfoIndustry.trademark_inside_info.nc" class="table">
              <div ref="treemap1" class="treemap"></div>
              <!-- <div v-else class="notData">暂无数据</div> -->
            </div>
            <div class="table" v-if="!PdfType">
              <el-table :data="companyInfoIndustry.trademark_inside_list.list" border style="width: 100%"
                :header-cell-style="{ background: '#f0f7fc' }" @row-click="rowClick(1, $event)">
                <el-table-column prop="fd" label="申请日期">
                  <template slot-scope="scope">
                    {{ scope.row.fd | time }}
                  </template>
                </el-table-column>
                <el-table-column prop="nc" label="类别"> </el-table-column>
                <el-table-column prop="mno" label="商标名称"> </el-table-column>
                <el-table-column prop="rn" label="注册号"> </el-table-column>
                <el-table-column prop="cs" label="状态"> </el-table-column>
              </el-table>
              <div class="more" @click="moreAdd(5, 1)">查看全部</div>
            </div>
            <div v-else>
              <table border="1" v-if="companyInfoIndustry.trademark_inside_list.list.length">
                <tr class="tableTr">
                  <th class="tableTh" align="center">申请日期</th>
                  <th class="tableTh" align="center">类别</th>
                  <th class="tableTh" align="center">商标名称</th>
                  <th class="tableTh" align="center">注册号</th>
                  <th class="tableTh" align="center">状态</th>
                </tr>
                <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.trademark_inside_list.list"
                  :key="'companyInfoIndustry.trademark_inside_list.list' + index">
                  <td class="tableTd" align="center">{{ item.fd | time }}</td>
                  <td class="tableTd" align="center">{{ item.nc }}</td>
                  <td class="tableTd" align="center">{{ item.mno }}</td>
                  <td class="tableTd" align="center">{{ item.rn }}</td>
                  <td class="tableTd" align="center">{{ item.cs }}</td>
                </tr>
              </table>
              <div v-else class="legendText">暂无数据</div>

              <div v-if="companyInfoIndustry.trademark_inside_list.list.length > 10 && PdfType" style="margin-top: 5px;">
                **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）</div>

            </div>
          </div>

          <!-- <div v-if="companyInfoIndustry.trademark_outside_info.es.nc"> -->
          <div>
            <div class="title">
              马德里商标：{{ companyInfoIndustry.trademark_outside_list.es.count }}
            </div>
            <div class="table" v-if="companyInfoIndustry.trademark_outside_info.es.nc">
              <div ref="treemap2" class="treemap"></div>
              <!-- <div v-else class="notData">暂无数据</div> -->
            </div>
            <div class="table" v-if="!PdfType">
              <el-table :data="companyInfoIndustry.trademark_outside_list.es.list" border style="width: 100%"
                @row-click="rowClick(2, $event)" :header-cell-style="{ background: '#f0f7fc' }">
                <el-table-column prop="fd" label="申请日期">
                  <template slot-scope="scope">
                    {{ scope.row.fd | time }}
                  </template>
                </el-table-column>

                <el-table-column prop="nc" label="类别"> </el-table-column>

                <el-table-column prop="tmog" label="商标">
                  <template slot-scope="scope">
                    <el-image :src="scope.row.tmsg" fit="cover"> </el-image>
                  </template>
                </el-table-column>
                <el-table-column prop="mno" label="商标名称"> </el-table-column>
                <el-table-column prop="rn" label="注册号"> </el-table-column>
                <el-table-column prop="cs" label="状态"> </el-table-column>
              </el-table>
              <div class="more" @click="moreAdd(5, 2)">查看全部</div>
            </div>
            <div v-else>
              <table border="1" v-if="companyInfoIndustry.trademark_outside_list.es.list.length">
                <tr class="tableTr">
                  <th class="tableTh" align="center">申请日期</th>
                  <th class="tableTh" align="center">类别</th>
                  <th class="tableTh" align="center">商标</th>
                  <th class="tableTh" align="center">商标名称</th>
                  <th class="tableTh" align="center">注册号</th>
                  <th class="tableTh" align="center">状态</th>
                </tr>
                <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.trademark_outside_list.es.list"
                  :key="'companyInfoIndustry.trademark_outside_list.es.list' + index">
                  <td class="tableTd" align="center">{{ item.fd | time }}</td>
                  <td class="tableTd" align="center">{{ item.nc }}</td>
                  <td class="tableTd" align="center">
                    <el-image :src="item.tmsg" fit="cover"> </el-image>
                  </td>
                  <td class="tableTd" align="center">{{ item.mno }}</td>
                  <td class="tableTd" align="center">{{ item.rn }}</td>
                  <td class="tableTd" align="center">{{ item.cs }}</td>
                </tr>
              </table>
              <div v-else class="legendText">暂无数据</div>

              <div v-if="companyInfoIndustry.trademark_outside_list.es.list.length > 10 && PdfType" style="margin-top: 5px;">
                **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）</div>
            </div>
          </div>

          <div>
            <!-- <div v-if="companyInfoIndustry.trademark_outside_info.us.nc"> -->
            <div class="title">
              美国商标：{{ companyInfoIndustry.trademark_outside_list.us.count }}
            </div>
            <div class="table" v-if="companyInfoIndustry.trademark_outside_info.us.nc">
              <div ref="treemap2" class="treemap"></div>
              <!-- <div v-else class="notData">暂无数据</div> -->
            </div>
            <div class="table" v-if="!PdfType">
              <el-table :data="companyInfoIndustry.trademark_outside_list.us.list" border style="width: 100%"
                @row-click="rowClick(2, $event)" :header-cell-style="{ background: '#f0f7fc' }">
                <el-table-column prop="fd" label="申请日期">
                  <template slot-scope="scope">
                    {{ scope.row.fd | time }}
                  </template>
                </el-table-column>

                <el-table-column prop="nc" label="类别"> </el-table-column>

                <el-table-column prop="tmog" label="商标">
                  <template slot-scope="scope">
                    <el-image :src="scope.row.tmsg" fit="cover"> </el-image>
                  </template>
                </el-table-column>
                <el-table-column prop="mno" label="商标名称"> </el-table-column>
                <el-table-column prop="rn" label="注册号"> </el-table-column>
                <el-table-column prop="cs" label="状态"> </el-table-column>
              </el-table>
              <div class="more" @click="moreAdd(5, 3)">查看全部</div>
            </div>
            <div v-else>
              <table border="1" v-if="companyInfoIndustry.trademark_outside_list.us.list.length">
                <tr class="tableTr">
                  <th class="tableTh" align="center">申请日期</th>
                  <th class="tableTh" align="center">类别</th>
                  <th class="tableTh" align="center">商标</th>
                  <th class="tableTh" align="center">商标名称</th>
                  <th class="tableTh" align="center">注册号</th>
                  <th class="tableTh" align="center">状态</th>
                </tr>
                <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.trademark_outside_list.us.list"
                  :key="'companyInfoIndustry.trademark_outside_list.us.list' + index">
                  <td class="tableTd" align="center">{{ item.fd | time }}</td>
                  <td class="tableTd" align="center">{{ item.nc }}</td>
                  <td class="tableTd" align="center">
                    <el-image :src="item.tmsg" fit="cover"> </el-image>
                  </td>
                  <td class="tableTd" align="center">{{ item.mno }}</td>
                  <td class="tableTd" align="center">{{ item.rn }}</td>
                  <td class="tableTd" align="center">{{ item.cs }}</td>
                </tr>
              </table>
              <div v-else class="legendText">暂无数据</div>

              <div v-if="companyInfoIndustry.trademark_outside_list.us.list.length > 10 && PdfType" style="margin-top: 5px;">
                **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）</div>
            </div>
          </div>

          <!-- <div v-if="companyInfoIndustry.trademark_outside_info.jp.nc"> -->
          <div>
            <div class="title" >
              日本商标：{{ companyInfoIndustry.trademark_outside_list.jp.count }}
            </div>
            <div class="table" v-if="companyInfoIndustry.trademark_outside_info.jp.nc">
              <div ref="treemap2" class="treemap"></div>
            </div>
            <div class="table" v-if="!PdfType">
              <el-table :data="companyInfoIndustry.trademark_outside_list.jp.list" border style="width: 100%"
                @row-click="rowClick(2, $event)" :header-cell-style="{ background: '#f0f7fc' }">
                <el-table-column prop="fd" label="申请日期">
                  <template slot-scope="scope">
                    {{ scope.row.fd | time }}
                  </template>
                </el-table-column>

                <el-table-column prop="nc" label="类别"> </el-table-column>

                <el-table-column prop="tmog" label="商标">
                  <template slot-scope="scope">
                    <el-image :src="scope.row.tmsg" fit="cover"> </el-image>
                  </template>
                </el-table-column>
                <el-table-column prop="mno" label="商标名称"> </el-table-column>
                <el-table-column prop="rn" label="注册号"> </el-table-column>
                <el-table-column prop="cs" label="状态"> </el-table-column>
              </el-table>
              <div class="more" @click="moreAdd(5, 4)">查看全部</div>
            </div>
            <div v-else>
              <table border="1" v-if="companyInfoIndustry.trademark_outside_list.jp.list.length">
                <tr class="tableTr">
                  <th class="tableTh" align="center">申请日期</th>
                  <th class="tableTh" align="center">类别</th>
                  <th class="tableTh" align="center">商标</th>
                  <th class="tableTh" align="center">商标名称</th>
                  <th class="tableTh" align="center">注册号</th>
                  <th class="tableTh" align="center">状态</th>
                </tr>
                <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.trademark_outside_list.jp.list"
                  :key="'companyInfoIndustry.trademark_outside_list.jp.list' + index">
                  <td class="tableTd" align="center">{{ item.fd | time }}</td>
                  <td class="tableTd" align="center">{{ item.nc }}</td>
                  <td class="tableTd" align="center">
                    <el-image :src="item.tmsg" fit="cover"> </el-image>
                  </td>
                  <td class="tableTd" align="center">{{ item.mno }}</td>
                  <td class="tableTd" align="center">{{ item.rn }}</td>
                  <td class="tableTd" align="center">{{ item.cs }}</td>
                </tr>
              </table>
              <div v-else class="legendText">暂无数据</div>

              <div v-if="companyInfoIndustry.trademark_outside_list.jp.list.length > 10 && PdfType" style="margin-top: 5px;">
                **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）</div>
            </div>
          </div>

          <div>
            <!-- <div v-if="companyInfoIndustry.trademark_outside_info.de.nc"> -->
            <div class="title">
              德国商标：{{ companyInfoIndustry.trademark_outside_list.de.count }}
            </div>
            <div class="table" v-if="companyInfoIndustry.trademark_outside_info.de.nc">
              <div ref="treemap2" class="treemap"></div>
              <!-- <div v-else class="notData">暂无数据</div> -->
            </div>
            <div class="table" v-if="!PdfType">
              <el-table :data="companyInfoIndustry.trademark_outside_list.de.list" border style="width: 100%"
                @row-click="rowClick(2, $event)" :header-cell-style="{ background: '#f0f7fc' }">
                <el-table-column prop="fd" label="申请日期">
                  <template slot-scope="scope">
                    {{ scope.row.fd | time }}
                  </template>
                </el-table-column>

                <el-table-column prop="nc" label="类别"> </el-table-column>

                <el-table-column prop="tmog" label="商标">
                  <template slot-scope="scope">
                    <el-image :src="scope.row.tmsg" fit="cover"> </el-image>
                  </template>
                </el-table-column>
                <el-table-column prop="mno" label="商标名称"> </el-table-column>
                <el-table-column prop="rn" label="注册号"> </el-table-column>
                <el-table-column prop="cs" label="状态"> </el-table-column>
              </el-table>
              <div class="more" @click="moreAdd(5, 5)">查看全部</div>
            </div>

            <div v-else>
              <table border="1" v-if="companyInfoIndustry.trademark_outside_list.de.list.length">
                <tr class="tableTr">
                  <th class="tableTh" align="center">申请日期</th>
                  <th class="tableTh" align="center">类别</th>
                  <th class="tableTh" align="center">商标</th>
                  <th class="tableTh" align="center">商标名称</th>
                  <th class="tableTh" align="center">注册号</th>
                  <th class="tableTh" align="center">状态</th>
                </tr>
                <tr class="tableTr" v-for="(item, index) in companyInfoIndustry.trademark_outside_list.de.list"
                  :key="'companyInfoIndustry.trademark_outside_list.de.list' + index">
                  <td class="tableTd" align="center">{{ item.fd | time }}</td>
                  <td class="tableTd" align="center">{{ item.nc }}</td>
                  <td class="tableTd" align="center">
                    <el-image :src="item.tmsg" fit="cover"> </el-image>
                  </td>
                  <td class="tableTd" align="center">{{ item.mno }}</td>
                  <td class="tableTd" align="center">{{ item.rn }}</td>
                  <td class="tableTd" align="center">{{ item.cs }}</td>
                </tr>
              </table>
              <div v-else class="legendText">暂无数据</div>

              <div v-if="companyInfoIndustry.trademark_outside_list.de.list.length > 10 && PdfType" style="margin-top: 5px;">
                **以上表格仅展示部分数据，更多信息请登录优专平台查看（zf.youpat.cn）</div>
            </div>
          </div>
        </div>

        <!-- <div v-else>
          暂无商标信息
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      data: {},
      detailsType: false,
    };
  },
  watch: {
    companyInfoIndustry: {
      handler(newVal, oldVal) {
        this.$nextTick((res) => {
          this.treemap("treemap1", 1);
          this.treemap("treemap2", 2);
        });
      },
      deep: true,
    },
  },
  filters: {
    //时间戳转换
    time(date) {
      // if (val) {
      //   return new Date(val).toLocaleString()
      // }
      date = new Date(date);
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      var d = date.getDate();
      d = d < 10 ? "0" + d : d;
      return y + "-" + m + "-" + d;
    },
  },
  props: {
    PdfType: {
      type: Boolean,
      default: false,
    },
    companyInfoIndustry: {
      type: Object,
      default: () => { },
    },
  },
  components: {},
  mounted() {
    this.$nextTick((res) => {
      this.treemap("treemap1", 1);
      this.treemap("treemap2", 2);
    });
  },
  methods: {
    back() {
      this.detailsType = false;
      this.$nextTick((res) => {
        this.treemap("treemap1", 1);
        this.treemap("treemap2", 2);
      });
    },
    treemap(name, type) {
      var chartDom = this.$refs[name];

      console.log(chartDom, 46314631365);
      if (!chartDom) {
        return;
      }

      var myChart = echarts.init(chartDom);

      let data = [];

      console.log(this.companyInfoIndustry, "asdasd");

      if (type == 1) {
        if (!this.companyInfoIndustry.trademark_inside_info.nc) {
          return;
        }
        if (this.companyInfoIndustry.trademark_inside_info.nc) {
          console.log(666);
          this.companyInfoIndustry.trademark_inside_info.nc.map((res) => {
            let obj = {
              name: "",
              value: 0,
            };
            obj.name = res.value;
            obj.value = res.count;
            data.push(obj);
          });
        }
      } else if (type == 2) {
        if (!this.companyInfoIndustry.trademark_outside_info.nc) {
          return;
        }
        this.companyInfoIndustry.trademark_outside_info.nc.map((res) => {
          let obj = {
            name: "",
            value: 0,
          };
          obj.name = res.value;
          obj.value = res.count;
          data.push(obj);
        });
      }

      var option = {
        label: {
          formatter: function (params) {
            let arr = ["类别：" + params.name, "数量：" + params.value];
            return arr.join("\n");
          },
        },
        tooltip: {
          formatter: function (info) {
            return [
              "<div>类别" + info.name + "</div>",
              "<div>数量" + info.value + "</div> ",
            ].join("");
          },
        },
        series: [
          {
            type: "treemap",
            data: data,
          },
        ],
      };
      option && myChart.setOption(option);
    },
    moreAdd(type, index) {
      // this.$router.push({
      //   path: "/morePatents",
      //   query: {
      //     patentType: type,
      //     company_id: this.companyInfoIndustry.company_id,
      //     status: index,
      //   },
      // });

      let routerJump = this.$router.resolve({
        path: "/morePatents",
        query: {
          patentType: type,
          company_id: this.companyInfoIndustry.company_id,
          status: index,
          companyName: this.companyInfoIndustry.company,
        },
      });
      window.open(routerJump.href, "_blank");
    },
    rowClick(status, row, column, event) {
      let routerJump;
      localStorage.setItem("trademarkData", JSON.stringify(row));
      routerJump = this.$router.resolve({
        path: "/morePatents",
        query: {
          patentType: 8,
          tid: row.tid,
          status: status,
          company_id: this.companyInfoIndustry.company_id,
        },
      });
      window.open(routerJump.href, "_blank");

      // this.data = row;
      // this.detailsType = true;
    },
  },
};
</script>

<style scoped lang="less">
.notData {
  text-align: center;
}

.treemap {
  width: 100%;
  height: 300px;
}

.more {
  text-align: center;
  padding: 20px;
  border-bottom: 1px solid #ebeef5;
  cursor: pointer;
}

.title {
  font-size: 18px;
  font-weight: bold;
}

.table {
  padding: 20px 0px;
}

.institutionName {
  margin: 30px 0 20px 0;
  font-size: 14px;
}

.newinstitutionName {
  margin: 40px 0;
  font-size: 14px;

  div {
    margin-bottom: 10px;
    line-height: 20px;

    span {
      background-color: #ff5f59;
      border-radius: 2px;
      color: #fff;
      font-size: 11px;
      padding: 0px 3px;
      margin-left: 5px;
      box-sizing: border-box;
      display: inline-block;
    }
  }
}

.PatentType {
  display: flex;

  .item {
    background-color: #f2f3f5;
    border-radius: 10px;
    border: 1px solid #3677f5;
    padding: 20px 0;
    width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    margin-right: 30px;
    cursor: pointer;

    .value {
      color: #3677f5;
      font-size: 16px;
      margin-bottom: 4px;
    }

    .number {
      font-size: 30px;
    }
  }

  .item2 {
    background-color: #3677f5;

    .value {
      color: #fff;
    }

    .number {
      color: #fff;
    }
  }
}

.echartsBox {
  width: 100%;
  height: 100%;
}

.echarts {
  padding: 20px 0px;
  display: flex;

  .left {
    width: 100px;

    .activation {
      color: #006cff;
    }

    div {
      margin-bottom: 10px;
      cursor: pointer;
    }
  }

  .right {
    flex: 1;
  }
}

@media (max-width: 1360px) {}

@media (max-width: 1280px) {}

@media (max-width: 768px) {}
</style>
